package com.homer.gps.track.persist;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "points")
public class PointModel {
	public final static String ID_FIELD_ROUTE_ID = "route_id";
	
	@DatabaseField(generatedId = true)
	private int id;
	
	@DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = ID_FIELD_ROUTE_ID)
	private RouteModel route;
	@DatabaseField(canBeNull = true)
	private double longitude;
	@DatabaseField(canBeNull = true)
	private double latitude;
	
	public PointModel(){
		// all persisted classes must define a no-arg constructor with at least package visibility
	}
	
	public PointModel(double longitude, double latitude, final RouteModel route) {
		super();
		this.route = route;
		this.longitude = longitude;
		this.latitude = latitude;
	}


	public double getLongitude() {
		return longitude;
	}


	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}


	public double getLatitude() {
		return latitude;
	}


	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	
	public void setRoute(final RouteModel route) {
		this.route = route;
	}

	public RouteModel getRoute() {
		return this.route;
	}

	public int getId() {
		return id;
	}

	public void setId(final int id) {
		this.id = id;
	}
	
	public final boolean hasId() {
		return 0 != this.id;
	}

}
